<template>
  <div class="title">
	<h2>当前求和为: {{ $store.state.sum }} </h2>
	<select v-model.number="n">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
	</select>
	<button @click="jia">+</button>
	<button @click="jian">-</button>
	<button @click="ji">当前和为奇数再加</button>
	<button @click="slide">等一等再加</button>
  </div>
</template>

<script>

export default {
  name: 'App',
  data() {
	return {
		n:1 //用户选择数字
	}
  },
  methods: {
	jia(){
		this.$store.commit('JIA',this.n)
	},
	jian(){
		this.$store.commit('JIAN',this.n)
	},
	ji(){
		this.$store.dispatch('ji',this.n)
	},
	slide(){
		this.$store.dispatch('slide',this.n)
	}
  }
}
</script>

<style scoped>
.title {
  margin: 0 auto;
  display: flex;
}
</style>

